package com.pets.web.controller.admin;


import com.fasterxml.jackson.databind.ser.Serializers;
import com.pets.common.core.controller.BaseController;
import com.pets.common.core.domain.AjaxResult;
import com.pets.common.core.page.TableDataInfo;
import com.pets.web.entity.PetsShop;
import com.pets.web.service.IPetsShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 店铺表 前端控制器
 * </p>
 *
 * @author zhurenwang
 * @since 2024-05-24
 */
@RestController
@RequestMapping("/shop")
public class PetsShopController extends BaseController {

    @Autowired
    private IPetsShopService petsShopService;

    @GetMapping("/list")
    public TableDataInfo list(){
        startPage();
        List<PetsShop> list = petsShopService.list();
        return getDataTable(list);
    }

    @PostMapping()
    public AjaxResult add(@RequestBody PetsShop petsShop){
        return success(petsShopService.add(petsShop));
    }

    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable Integer id){
        return success(petsShopService.deleteById(id));
    }

    @GetMapping("/{id}")
    public AjaxResult get(@PathVariable Integer id){
        return success(petsShopService.getById(id));
    }

    @PutMapping()
    public AjaxResult edit(@RequestBody PetsShop petsShop){
        return success(petsShopService.updateById(petsShop));
    }

}
